package cn.huihuo.weibo.module;

import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;

/**
 * @author Dan
 * Created by Administrator on 2015/8/27.
 */
public class Product extends Model<Product> {
    public static final Product product = new Product();

    public Product findBySkuId(String skuId){
        return findFirst("select * from product t where t.sku_id=?", skuId);
    }

    //获取商品id
    public Product findByProductId(String prodId){
        return findFirst("SELECT p.id prodId,p.prod_url,p.prod_title,p.price,pic.out_pic_path,pic.inner_pic_path FROM product p,productpic pic WHERE p.defult_pic_id=pic.id and p.id=?",prodId);
    }

    public Page<Product> findAllHot(Integer pageNumber,Integer pageSize){
        return paginate( pageNumber, pageSize,"SELECT h.interaction,h.interaction_user,pc.out_pic_path,pc.inner_pic_path,p.prod_title,p.id prodId "," FROM product_hot h,product p,productpic pc WHERE  h.prod_id=p.id AND p.defult_pic_id=pc.id and is_use = 1 and interaction != 0  ORDER BY h.interaction DESC");
    }

}
